<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>家长身份绑定</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
</head>
<body ontouchstart>
	<div class="weui_tab tab-bottom">
		<div class="weui_tab_bd">
			<div class="weui-header bg-blue"> 
		  		<div class="weui-header-left"> <a onclick="back()" href="javascript:" class="icon icon-109 f-white">返回</a> </div>
		    	<h1 class="weui-header-title">家长身份绑定</h1>
		    </div>
			<div class="weui_cells weui_cells_form" style="margin: 0;">
				<div class="page-hd">
					<div class="tcenter"><img class="circle" width="100" height="100" src="<%=basePath %>/images/logo.jpg"/></div>
	            	<div class="tcenter">石门实验中学家长身份绑定</div>
				</div>
				<form id="studentBindForm">
					<div class="weui_cell">
		                <div class="weui_cell_hd"><label class="weui_label">小孩姓名：</label></div>
		                <div class="weui_cell_bd weui_cell_primary">
		                    <input class="weui_input" id="studentName" name="studentName" type="text" placeholder="请输入小孩姓名"/>
		                </div>
		            </div>
					<div class="weui_cell">
		                <div class="weui_cell_hd"><label class="weui_label">小孩身份证：</label></div>
		                <div class="weui_cell_bd weui_cell_primary">
		                    <input class="weui_input" id="idNo" name="idNo" type="text" placeholder="请输入小孩身份证"/>
		                </div>
		            </div>
		        </form>
			</div>
			<div class="weui_btn_area">
		        <a href="javascript:" id="teacherBind" class="weui_btn weui_btn_primary">绑定身份</a>
		   </div>
		</div>
	</div>
	<script type="text/javascript">
		$("#teacherBind").click(function() {
			if($("#studentName").val() == "") {
				$.toast("小孩姓名不能为空");
				return false;
	    	}
	    	if($("#idNo").val() == "") {
	    		$.toast("小孩身份证不能为空");
				return false;
	    	}
	    	$.ajax({
	    		url: basePath + "/student/bind/submit",
	    		type: 'POST',
	    		dataType : "json",
	    		data: $('#studentBindForm').serialize(),
	    		success: function(data) {
	    			if (data.code != "000") {
	    				$("#idNo").val(null);
	    				$("#studentName").val(null);
	    				$.toast(data.msg);
	    			} else {
	    				$.toast("尊敬的 " +data.data.name + " 家长，恭喜你绑定成功");
	    				var redirectUrl = queryStringByName("redirectUrl");
	    				if(redirectUrl == null) {
	    					redirectUrl = basePath + "/xs?sid=" + data.data.studentId;
	    				}
	    				setTimeout("javascript:location.href='"+redirectUrl+"'", 1000); 
	    			}
	    		},
	    		error: function(data) {
	    			alert("系统异常,请联系管理员");
	    		}
	    	});
		})
	</script>
</body>
</html>